package org.meb.conquest.web;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

@FacesConverter(value = "cardStatConverter")
public class CardStatConverter implements Converter {

	@Override
	public Object getAsObject(FacesContext context, UIComponent component, String string) {
		return "X".equals(string) ? new Integer(-1) : Integer.valueOf(string);
	}

	@Override
	public String getAsString(FacesContext arg0, UIComponent arg1, Object object) {
		return new Integer(-1).equals(object) ? "X" : (object == null ? null : object.toString());
	}
}
